package kr.saeildamil.androidstudy.ch19;

import kr.saeildamil.androidstudy.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class JobSchedulePost extends Activity {
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch19_jobscheduletest);
		
		findViewById(R.id.ch19_jobscheduletest_upload).setOnClickListener(new OnClickListener() {	
			public void onClick(View v) {
				new AlertDialog.Builder(JobSchedulePost.this)
				.setTitle("질문")
				.setMessage("업로드 ㄱㄱ??")
				.setPositiveButton("ㅇㅇ", new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						//mHandler.sendEmptyMessageAtTime(0, 10);;
						/*mHandler.postDelayed(new Runnable() {						
							public void run() {
								upUpload();
							}
						}, 10);*/
						Button button = (Button) findViewById(R.id.ch19_jobscheduletest_upload);
						button.postDelayed(new Runnable() {
							public void run() {
								upUpload();
							}
						}, 10);
					}
				})
				.setNegativeButton("ㄴㄴ", null)
				.show();
			}
		});
	}
	
	/*Handler mHandler = new Handler(){
		public void handleMessage(Message msg) {
			super.handleMessage(msg);
			upUpload();
		}		
	};*/
	public void upUpload() {
		for(int i=0; i<20; i++){
			try {
				Thread.sleep(500);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		Toast.makeText(this, "업로드완료함!", Toast.LENGTH_LONG).show();
		
	}
}
